<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>遍历数组</title>
</head>
<body>
<input type="button" id="btn" value="遍历列表项">
<ul>
    <li>拉布拉多</li>
    <li>金毛</li>
    <li>萨摩耶</li>
</ul>
</body>
<script src="js/jquery-3.3.1.min.js"></script>
<script>
    //$.each
/*    $("#btn").click(function () {
        let lis = $("li");
        $.each(lis, function (index,ele) {
            alert(index+"-"+ele.innerText)
        })
    })*/
    //对象名.each
    $("#btn").click(function () {
        let lis = $("li");
        lis.each(function () {
            alert(this.innerText)
        })
    })

    $("#btn").click(function () {
        let lis = $("li");
        lis.each(function (index,ele) {
            alert(index+"-"+ele.innerText)
        })
    })
</script>
</html>